package com.zhj.leetcode;

/**
 * 力扣 485 获取最大连续1的个数
 * @author zhj
 */
public class Test485 {
    public static void main(String[] args) {
        int[] arr = new int[]{1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1};
        System.out.println(getNum(arr));
    }

    private static int getNum(int[] arr) {
        if (arr == null || arr.length == 0)
            return 0;
        int count = 0;
        int result = 0;
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] == 1)
                count++;
            else {
                result = result < count ? count : result;
                count = 0;
            }
        }
        return result < count  ? count : result;
    }
}
